package com.seckill.service;

import com.seckill.domain.MiaoshaOrder;
import com.seckill.rabbitmq.MiaoshaMessage;

/**
 * @author yangjunwei
 * @date 2021/11/2 9:38 上午
 */
public interface MiaoshaOrderService {

    /**
     * 创建秒杀订单 判断库存->是否秒杀过->减库存->创建订单->创建秒杀订单->订单支付倒计时
     *
     * @param miaoshaMessage 秒杀信息
     */
    void doMiaoshaOrder(MiaoshaMessage miaoshaMessage);

    /**
     * 查询秒杀订单
     */
    MiaoshaOrder selectUserOrderForCache(long goodsId, long userId);

    /**
     * 删除用户缓存中的秒杀订单
     */
    boolean deleteUserGoodsCache(long goodsId, long userId);

    /**
     * 商品还有库存的情况，走缓存判断用户是否参与过秒杀
     * @param goodsId
     * @param userId
     */
    void checkUserMiaosha(Long goodsId, Long userId);

    MiaoshaOrder selectMiaoshaOrderByParam(Long goodsId, Long userId);

    int deleteMiaoshaOrder(Long goodsId, Long userId);


}
